<html>
<head><meta charset="utf-8"><title>Determinism in const eval · t-compiler/const-eval · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/index.html">t-compiler/const-eval</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html">Determinism in const eval</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="189533440"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/189533440" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Elichai Turkel <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#189533440">(Mar 02 2020 at 20:36)</a>:</h4>
<p>Hi, I'm watching <span class="user-mention" data-user-id="124288">@oli</span>'s talk in RustConf and I just wanted to comment about determinism, I do think that non determinism can be a wanted feature specifically the one you mentioned generating randomness,<br>
Right now there are crates like <a href="https://github.com/tkaitchuck/constrandom" target="_blank" title="https://github.com/tkaitchuck/constrandom">https://github.com/tkaitchuck/constrandom</a> for providing something that could've easily happened in a const fn</p>



<a name="189611485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/189611485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#189611485">(Mar 03 2020 at 16:53)</a>:</h4>
<p>True randomness in const eval would break our type system. You could end up with a situation where two arrays of different lengths are considered equal types. Also the query system likely would break in horrible ways</p>



<a name="191492374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/191492374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#191492374">(Mar 23 2020 at 15:44)</a>:</h4>
<p>also that kind of crate is just terrible for deterministic builds</p>



<a name="191492462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/191492462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#191492462">(Mar 23 2020 at 15:44)</a>:</h4>
<p>oh it's <em>the same one</em></p>



<a name="191492510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/191492510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#191492510">(Mar 23 2020 at 15:45)</a>:</h4>
<p><span class="user-mention" data-user-id="249222">@Elichai Turkel</span> that crate broke determinism for all users of <code>hashbrown</code>, by default</p>



<a name="191492557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/191492557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#191492557">(Mar 23 2020 at 15:45)</a>:</h4>
<p>I hit this while investigating non-deterministic build causes for a client</p>



<a name="191493011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/191493011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> HeroicKatora <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#191493011">(Mar 23 2020 at 15:48)</a>:</h4>
<p>How are <code>static</code> differentiated from <code>const</code> in the compiler? Maybe it could be somehow allowed to have random statics but not random constants, as the former can't be used in types.</p>



<a name="191493115"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/191493115" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#191493115">(Mar 23 2020 at 15:49)</a>:</h4>
<p>what, link-time RNG?</p>



<a name="191493149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/191493149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#191493149">(Mar 23 2020 at 15:49)</a>:</h4>
<p>it's still a terrible idea because non-deterministic builds</p>



<a name="191493193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/191493193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#191493193">(Mar 23 2020 at 15:49)</a>:</h4>
<p>just load randomness at runtime</p>



<a name="191493373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/191493373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#191493373">(Mar 23 2020 at 15:50)</a>:</h4>
<p>computing non-determinism during the build process is the worst of all worlds</p>



<a name="191493591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/191493591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#191493591">(Mar 23 2020 at 15:52)</a>:</h4>
<p>if you want to inject a seed into your builds, use an env variable (or a build script that extracts it from somewhere controllable), at least then you can reproduce the same build (this could be e.g. a <code>git</code> hash)</p>



<a name="191493686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/191493686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#191493686">(Mar 23 2020 at 15:52)</a>:</h4>
<p>if you just want RNG at runtime, do it right</p>



<a name="191501486"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/191501486" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#191501486">(Mar 23 2020 at 16:43)</a>:</h4>
<p>agreed with @eddyb -- it is crucial to be able to exactly re-construct a bianary. that is pretty much the only technique we have to prove that a given binary actually comes from a given sourcecode.</p>



<a name="191501537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/191501537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#191501537">(Mar 23 2020 at 16:43)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> is there an issue for the hashbrown nondet?</p>



<a name="191507655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/191507655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#191507655">(Mar 23 2020 at 17:25)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> <a href="https://github.com/rust-lang/hashbrown/pull/125" target="_blank" title="https://github.com/rust-lang/hashbrown/pull/125">https://github.com/rust-lang/hashbrown/pull/125</a></p>



<a name="191509084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/191509084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#191509084">(Mar 23 2020 at 17:34)</a>:</h4>
<p>but that doesnt sound like anyone was concerned with reproducible builds? (which is itself quite concerning)</p>



<a name="191509926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/191509926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Elichai Turkel <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#191509926">(Mar 23 2020 at 17:40)</a>:</h4>
<p>You're right.<br>
I didn't think it through, non determinism in the binary is a bad idea.</p>



<a name="191512099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/191512099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#191512099">(Mar 23 2020 at 17:56)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> there's this I guess <a href="https://github.com/paritytech/trie/pull/36" target="_blank" title="https://github.com/paritytech/trie/pull/36">https://github.com/paritytech/trie/pull/36</a></p>



<a name="191512167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/191512167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#191512167">(Mar 23 2020 at 17:57)</a>:</h4>
<p>it links everything I could find on the subject at the time</p>



<a name="191513046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/191513046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Elichai Turkel <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#191513046">(Mar 23 2020 at 18:03)</a>:</h4>
<p>Arghh I wouldn't switch to ahash that easily :/.<br>
It's not peer reviewed, there's not even a paper analyzing it or proving that the hash function construction is as secure as the aes function.<br>
But it's off topic so sorry.</p>



<a name="191513339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/191513339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#191513339">(Mar 23 2020 at 18:04)</a>:</h4>
<p>I've heard similar things, don't worry</p>



<a name="191513422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/191513422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#191513422">(Mar 23 2020 at 18:05)</a>:</h4>
<p>it couldn't be as secure as AES, it's presumably DoS-protection-only (but I doubt it's as good as, idk, SipHash)</p>



<a name="191559832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/191559832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#191559832">(Mar 24 2020 at 01:51)</a>:</h4>
<p>not to mention its not reproducible across architectures...</p>



<a name="192177840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/192177840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Elichai Turkel <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#192177840">(Mar 29 2020 at 14:45)</a>:</h4>
<p><a href="https://github.com/tkaitchuck/constrandom/pull/13" title="https://github.com/tkaitchuck/constrandom/pull/13">https://github.com/tkaitchuck/constrandom/pull/13</a> :)</p>



<a name="192178354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/192178354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#192178354">(Mar 29 2020 at 14:57)</a>:</h4>
<p>cc-ing <span class="user-mention" data-user-id="119235">@David Tolnay</span> on this thread, I guess (the env var thing should already suffice to make this reasonable, IMO)</p>



<a name="192178408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/192178408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#192178408">(Mar 29 2020 at 14:58)</a>:</h4>
<p>although the default "every build gets randomness" still seems potentially misguided, it's good to have workarounds</p>



<a name="192178544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/192178544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Tolnay <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#192178544">(Mar 29 2020 at 15:01)</a>:</h4>
<p>oh yeah screw that crate</p>



<a name="192178601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/192178601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#192178601">(Mar 29 2020 at 15:02)</a>:</h4>
<p>lol</p>



<a name="192178609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/192178609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#192178609">(Mar 29 2020 at 15:03)</a>:</h4>
<p>:(</p>



<a name="192178615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/192178615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#192178615">(Mar 29 2020 at 15:03)</a>:</h4>
<p>AFAIK hashbrown is the only real user of constrandom.</p>



<a name="192178623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/192178623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#192178623">(Mar 29 2020 at 15:03)</a>:</h4>
<p><span class="user-mention" data-user-id="119235">@David Tolnay</span> I found out about it while trying to get a combined host + wasm build deterministic, late last year, and I'm glad I started with same-directory builds before going to different-directory</p>



<a name="192178682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/192178682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#192178682">(Mar 29 2020 at 15:04)</a>:</h4>
<p>Actually no, it seems a lot of crates are using <code>ahash</code>.</p>



<a name="192178684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/192178684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#192178684">(Mar 29 2020 at 15:04)</a>:</h4>
<p>there was this and there was a bug in wasm debuginfo generation (UB in C++, reading from uninitialized variables), IIRC</p>



<a name="192178710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/192178710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#192178710">(Mar 29 2020 at 15:05)</a>:</h4>
<p>/me is considering just disabling the "ahash-compile-time-rng" feature by default since so many people are complaining about it...</p>



<a name="192178775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/192178775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Tolnay <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#192178775">(Mar 29 2020 at 15:06)</a>:</h4>
<p>i hit it because our codebase needs a concurrent hashmap</p>



<a name="192178779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/192178779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Tolnay <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#192178779">(Mar 29 2020 at 15:06)</a>:</h4>
<p>chashmap is unusable due to race conditions</p>



<a name="192178780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/192178780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Tolnay <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#192178780">(Mar 29 2020 at 15:06)</a>:</h4>
<p>dashmap is unusable due to const_random</p>



<a name="192178793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/192178793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Tolnay <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#192178793">(Mar 29 2020 at 15:07)</a>:</h4>
<p>we've ended up using a deterministic fork of dashmap</p>



<a name="192178946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/192178946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#192178946">(Mar 29 2020 at 15:10)</a>:</h4>
<p>ddashmap? :P</p>



<a name="192179009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/192179009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#192179009">(Mar 29 2020 at 15:12)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Determinism.20in.20const.20eval/near/192178408" title="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Determinism.20in.20const.20eval/near/192178408">said</a>:</p>
<blockquote>
<p>although the default "every build gets randomness" still seems potentially misguided, it's good to have workarounds</p>
</blockquote>
<p>yeah, I feel the default should be reproducible. I am also not convinced build-time randomness is sufficient defense against hashDoS attacks. it feels more like papering over the issue...</p>



<a name="192179016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/192179016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#192179016">(Mar 29 2020 at 15:12)</a>:</h4>
<p><span class="user-mention silent" data-user-id="143274">Amanieu</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Determinism.20in.20const.20eval/near/192178682" title="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Determinism.20in.20const.20eval/near/192178682">said</a>:</p>
<blockquote>
<p>Actually no, it seems a lot of crates are using <code>ahash</code>.</p>
</blockquote>
<p>I wonder how many of those went "ah it's used by hashbrown, so it must be high quality"...</p>



<a name="192179203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/192179203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#192179203">(Mar 29 2020 at 15:16)</a>:</h4>
<p>haha Q_Q</p>



<a name="192391239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Determinism%20in%20const%20eval/near/192391239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Elichai Turkel <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Determinism.20in.20const.20eval.html#192391239">(Mar 31 2020 at 13:45)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Determinism.20in.20const.20eval/near/192179009" title="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Determinism.20in.20const.20eval/near/192179009">said</a>:</p>
<blockquote>
<p>yeah, I feel the default should be reproducible. I am also not convinced build-time randomness is sufficient defense against hashDoS attacks. it feels more like papering over the issue...</p>
</blockquote>
<p>I'm not even convinced aHash is sufficient to defend against hashDoS attack anyway.<br>
I think Abseil's hashmap uses CityHash, which AFAICT isn't secure against hashDoS either, so i'm not sure if the default should be secure or not</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>